package com.qfedu.dao.impl;

import com.qfedu.dao.AccountDao;
import com.qfedu.mapper.AccountRowMapper;
import com.qfedu.pojo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("accountDao")
public class AccountDaoImpl implements AccountDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
//
//    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
//        this.jdbcTemplate = jdbcTemplate;
//    }



    public Account findAccountByName(String accountName) {
        List<Account> accounts = jdbcTemplate.query("select * from account where name=?", new AccountRowMapper(), accountName);
        return accounts.get(0);
    }




    public void updateAccount(Account account) {

        jdbcTemplate.update("update account set money= ? where id=?",account.getMoney(),account.getId());

    }
}

